﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using XmlStudio.Interfaces;
using XmlStudio.Models;

namespace XmlStudio.Tests.XsdTests {
    [TestClass]
    public class XsdModelTest {
        IXsdModel model;

        [TestInitialize]
        public void MyTestInitialize() {
            this.model = ModelFactory.CreateXsdModel();
        }

        [TestMethod]
        public void TestListNamedSimpleAndComplexTypes() {
            model.Open(Common.PathShiporderXsd);
            model.ExpandAll();

            Assert.AreEqual<int>(29, model.NodeCount);
            var simpleTypes = model.ListNamedSimpleTypes();
            Assert.IsNotNull(simpleTypes);
            Assert.AreEqual<int>(4, simpleTypes.Count());

            var complexTypes = model.ListNamedComplexTypes();
            Assert.IsNotNull(complexTypes);
            Assert.AreEqual<int>(3, complexTypes.Count());
        }

        [TestMethod]
        public void TestListNamedElements() {
            model.Open(Common.PathXsdTest5);
            model.ExpandAll();

            var namedElements = model.ListNamedElements();
            Assert.IsNotNull(namedElements);
            Assert.AreEqual<int>(121, namedElements.Count());
        }

        [TestMethod]
        public void TestListNamedAttributeGroups() {
            model.Open(Common.PathXsdTest4);
            model.ExpandAll();

            var namedAttributeGroups = model.ListNamedAttributeGroups();
            Assert.IsNotNull(namedAttributeGroups);
            Assert.AreEqual<int>(1, namedAttributeGroups.Count());
        }

        [TestMethod]
        public void TestListBuiltInDataTypes() {
            var builtin = model.ListBuiltInDataTypes();
            Assert.IsNotNull(builtin);
            Assert.AreEqual<int>(44, builtin.Count());
        }
    }
}
